From c31f3be9b40d5d4703674b35081cfcbabd4ad8bb Mon Sep 17 00:00:00 2001 From: Andrew Cooper Date: Tue, 25 Oct 2016 19:41:01 +0100 Subject: [PATCH] x86/emul: Debugging improvements to the test harness Disable stdout buffering, so logging gets out even if the harness crashes. Add a verbose option (compile time disabled) which dumps all read/write calls the harness makes Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- tools/tests/x86_emulator/test_x86_emulator.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tools/tests/x86_emulator/test_x86_emulator.c b/tools/tests/x86_emulator/test_x86_emulator.c index b54fd11fe0..b5eca867f9 100644 --- a/tools/tests/x86_emulator/test_x86_emulator.c +++ b/tools/tests/x86_emulator/test_x86_emulator.c @@ -12,6 +12,8 @@ #include "x86_emulate/x86_emulate.h" #include "blowfish.h" +#define verbose false /* Switch to true for far more logging. */ + static const struct { const void *code; size_t size; @@ -47,6 +49,9 @@ static int read( unsigned int bytes, struct x86_emulate_ctxt *ctxt) { + if ( verbose ) + printf("** %s(%u, %p,, %u,)\n", __func__, seg, (void *)offset, bytes); + bytes_read += bytes; memcpy(p_data, (void *)offset, bytes); return X86EMUL_OKAY; @@ -59,6 +64,9 @@ static int fetch( unsigned int bytes, struct x86_emulate_ctxt *ctxt) { + if ( verbose ) + printf("** %s(%u, %p,, %u,)\n", __func__, seg, (void *)offset, bytes); + memcpy(p_data, (void *)offset, bytes); return X86EMUL_OKAY; } @@ -70,6 +78,9 @@ static int write( unsigned int bytes, struct x86_emulate_ctxt *ctxt) { + if ( verbose ) + printf("** %s(%u, %p,, %u,)\n", __func__, seg, (void *)offset, bytes); + memcpy((void *)offset, p_data, bytes); return X86EMUL_OKAY; } @@ -82,6 +93,9 @@ static int cmpxchg( unsigned int bytes, struct x86_emulate_ctxt *ctxt) { + if ( verbose ) + printf("** %s(%u, %p,, %u,)\n", __func__, seg, (void *)offset, bytes); + memcpy((void *)offset, new, bytes); return X86EMUL_OKAY; } @@ -233,6 +247,9 @@ int main(int argc, char **argv) unsigned int bcdres_native, bcdres_emul; #endif + /* Disable output buffering. */ + setbuf(stdout, NULL); + ctxt.regs = ®s; ctxt.force_writeback = 0; ctxt.addr_size = 8 * sizeof(void *); -- 2.30.2